feat(bench): repeatable memory-footprint benchmark (mem-bench.mjs + advisory workflow) - #406
Merged
Conversation
….mjs) Measures server RSS at lifecycle checkpoints (after-initialize = reaper barrier, after-tools-list, session-cycle retention) across targets (dist / npx bundle / docker), with a synthesized busy-/proc docker scenario (N sleeper processes spawned before exec, server as PID 1) to exercise the startup orphan reapers under a realistic process count. 5-trial median + min..max sampling, JSON output, and a compare subcommand whose significance test is median-shift vs full spread. Advisory weekly/dispatch CI workflow (never a required check). Motivated by PR #395's finding that unbounded /proc scans leave a permanent RSS scar; this makes such claims measurable and repeatable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ckout Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PR #395 showed that a memory claim about this server ("startup /proc scan leaves a permanent ~200 MB RSS scar") was measurable, repeatable, and fixable — but we had no tooling to make such claims cheap to verify or to catch regressions. This adds a repeatable memory-footprint benchmark so footprint decisions are driven by data instead of chance.
scripts/mem-bench.mjs(zero new dependencies — drives the server with the already-vendored MCP SDK client):after-initialize(startup floor — a successful MCPinitializeis a guaranteed barrier for reaper completion, since both reapers are awaited before argv parsing),after-tools-list(prices the adapter availability probe, perf(adapters): first tools/list imports and instantiates all 9 adapter packages permanently #401),after-session-cycle+ per-session RSS delta (retention signal).busy-procscenario (docker): spawns Nsleep infinityprocesses inside the container before exec'ing the server, so exactly N sleepers exist in/procwhen the reapers run and node is PID 1 — a controlled, repeatable stand-in for a busy host, no--pid=hostnondeterminism. Each trial runs a 0-sleeper control and an N-sleeper variant; the within-trial delta isolates scan cost.procEntryCountis recorded per trial so a failed spawn is visible, not silently wrong./proc/<pid>/statusVmRSS + VmHWM on Linux (peak proves a spike was prevented, not released — V8 doesn't return grown arenas),Get-ProcessWorkingSet64/PeakWorkingSet64/PrivateMemorySize64 on Windows,pson darwin,docker exec cat /proc/1/statusfor containers. Settle = 3 consecutive samples within max(2%, 2 MB).--trials(default 5); JSON output with git/host/config provenance;compare a.json b.jsonsubcommand marks a delta significant only when the median shift exceeds both runs' full spreads.bench:mem/bench:mem:docker;bench-results/gitignored..github/workflows/mem-bench.yml: advisory only — weekly cron + workflow_dispatch, ubuntu-only, results to step summary + uploaded JSON artifact. Never a required check, no thresholds, no PR trigger (shared-runner memory numbers are noisy; the local harness is the source of truth).Baselines at this commit
Windows host, dist target, 5 trials (all settled):
Docker (linux), busy-proc, 5 trials — the #395 verification this harness was first used for:
a4d5737d🔄 Type of Change
🧪 Testing
pnpm lintclean (script is covered byscripts/**lint glob)Related: #399 #400 #401 #402 #403 #404 #405 (the footprint follow-ups this data supports)
🤖 Generated with Claude Code